cmake_minimum_required(VERSION 3.10)

#set(CMAKE_CXX_STANDARD 14)

include_directories(.)

include_directories(../message)
include_directories(../service_base)
include_directories(../../common/msg)
include_directories(../../third/mongoose)
include_directories(../../common/utils)
include_directories(rknpu_src)
include_directories(rknpu_src/utils)
include_directories(${CMAKE_SOURCE_DIR}/${RKNN_ROOT}/include)
include_directories(${CMAKE_SOURCE_DIR}/${RKRGA_ROOT}/include)
include_directories(${CMAKE_SOURCE_DIR}/${STBIMAGE_ROOT}/include)
include_directories(${CMAKE_SOURCE_DIR}/${LIBJPEGTURBO_ROOT}/include)
link_directories(${CMAKE_SOURCE_DIR}/${RKNN_ROOT}/lib)
link_directories(${CMAKE_SOURCE_DIR}/${RKRGA_ROOT}/lib)
link_directories(${CMAKE_SOURCE_DIR}/${LIBJPEGTURBO_ROOT}/lib)

set(ENABLE_ASAN ON)
set(DISABLE_RGA OFF)

# only RGA on rv1106 and rk3588 support handle
if (TARGET_SOC STREQUAL "rv1106" OR TARGET_SOC STREQUAL "rk3588")
	add_definitions(-DLIBRGA_IM2D_HANDLE)
endif()
if(DISABLE_RGA AND NOT (TARGET_SOC STREQUAL "rv1106" OR TARGET_SOC STREQUAL "rv1103" OR TARGET_SOC STREQUAL "rv1103b"))
	add_definitions(-DDISABLE_RGA)
endif ()

if (${ARCH} STREQUAL "rk3588")
	add_definitions(-DRK3588)
	message("with rk3588 ${CMAKE_SOURCE_DIR}/${RKNN_ROOT}/include")
	set(IMPL_FILES
			CMAIServiceImplRk3588.cpp
			CMAIServiceImplRk3588.h
			rknpu_src/rknpu2/yolo11.cc
			rknpu_src/postprocess.cc
			rknpu_src/utils/file_utils.c
			rknpu_src/utils/file_utils.h
			rknpu_src/utils/image_utils.c
			rknpu_src/utils/image_utils.h
	)
endif ()

set(SOURCE_FILES
		${IMPL_FILES}
		CMAIServiceInterface.cpp
		CMAIServiceInterface.h
)

add_library(cm-ai-service
		${SOURCE_FILES}
		)

add_executable(cm_ai_service_test
		cm_ai_service_test.cpp
		${SOURCE_FILES}
)

target_link_libraries(cm_ai_service_test
		servicebase
		jkmessage
		net
		third_jsoncpp
		utils
		jkfuncs
		rknnrt
		rga
		turbojpeg jpeg
		dl
		pthread
)
